#pragma once

#include "barcodeart/IInput.hpp"
#include "barcodeart/qrencode/import_libqrencode.hpp"


namespace barcodeart
{

namespace qrencode
{

class QRInput : public IInput
{
public:
    QRInput() : m_pQRinput(clib::QRinput_new()), m_encodeMode(QR_MODE_NUL) {}
    QRInput(int version, ECLevel level) : m_pQRinput(clib::QRinput_new2(version, level)), m_encodeMode(QR_MODE_NUL) {}
    ~QRInput() { clib::QRinput_free(m_pQRinput); }

    static IInput::Ptr createFromString(const char* pString, int version, ECLevel ecLevel, EncodeMode hint, bool caseSensitive)
    {
        QRInput* pInput = 0;
        IInput::Ptr pResult(pInput = new QRInput(version, ecLevel));

        return pResult;
    }

    static int check(EncodeMode mode, const unsigned char *pData, int size)
    {
        return clib::QRinput_check(mode, size, pData);
    }

    void setEncodeMode(EncodeMode mode)
    {
        m_encodeMode = mode;
    }

    int append(const uint8_t *pData, int size)
    {
        return clib::QRinput_append(m_pQRinput, m_encodeMode, size, pData);
    }

//    int appendECIHeader(unsigned int eciNum)
//    {
//        return clib::QRinput_appendECIheader(m_pQRinput, eciNum);
//    }

    int setErrorCorrectionLevel(ECLevel ecLevel)
    {
        return clib::QRinput_setErrorCorrectionLevel(m_pQRinput, ecLevel);
    }

    ECLevel getErrorCorrectionLevel() const
    {
        return clib::QRinput_getErrorCorrectionLevel(m_pQRinput);
    }

    int setVersion(int value)
    {
        return clib::QRinput_setVersion(m_pQRinput, value);
    }

    int getVersion() const
    {
        return clib::QRinput_getVersion(m_pQRinput);
    }

    operator clib::QRinput*() const { return m_pQRinput; }

private:
    clib::QRinput* m_pQRinput;
    EncodeMode m_encodeMode;
};

}

}
